﻿
using SMARTMobile.Models;
using SMARTMobile.WinPhone;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using SMARTMobile.Models;
using SmartMobile.Data;
using SMARTMobile.Common;
using SMARTMobile.ViewModels;

namespace SMARTMobile.Views
{
    public partial class ThietDatPage
    {
        SmartMobileDBContext _smartMobileContext;
        ThietDatViewModel _viewModel;

        public ThietDatPage()
        {
            InitializeComponent();
            this._viewModel = new ThietDatViewModel();
            this.DataContext = this._viewModel;
            //this.Loaded += ThietDatPage_Loaded;
        }

        void ThietDatPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            this._viewModel = new ThietDatViewModel();
            this._viewModel.PageLoaded(null);
            this.DataContext = this._viewModel;
            this._viewModel.SetPreSelected();
        }

        private void ExitButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
        }

        private void DoiTuongLP_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            DoiTuongModel doituongSelected = new DoiTuongModel();
            doituongSelected = this.DoiTuongLP.SelectedItem as DoiTuongModel;
            if (doituongSelected.Code == "SS")
            {
                this.SaleSPLP.Visibility = System.Windows.Visibility.Collapsed;
                this.DistributorLP.Visibility = System.Windows.Visibility.Collapsed;
                this.SSLP.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.SaleSPLP.Visibility = System.Windows.Visibility.Visible;
                this.DistributorLP.Visibility = System.Windows.Visibility.Visible;
                this.SSLP.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        #region Method

        #endregion
    }
}